/*
 * ULSF Sagittarius IDA
 * Copyright (C) 2012, John Pritchard, all rights reserved.
 * 
 * This program is free software: you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see
 * <http://www.gnu.org/licenses/>.
 */
package sagittarius.design;

import sagittarius.Field;
import sagittarius.Visualization;

/**
 *
 * 
 * @see SearsHaackHyperbolicWing
 */
public abstract class VolumeHyperbolic
    extends Volume
{
    public static class Sector {

        public static class Default
            extends Sector
        {
            public Default(){
                super(2.0,4.0);
            }
        }


        public final double min, max, ds;


        public Sector(double min, double max){
            super();
            if (2.0 <= min && min < max){
                this.min = min;
                this.max = max;
                this.ds = (max-min)/(Model.Top-1);
            }
            else
                throw new Error();
        }


        public float model(double uniform, double station){
            final double fit = (uniform*(Model.Top-1));
            return (float)(this.min+(fit*this.ds));
        }
        public float sector(double sector){
            return (float)(sector/this.max);
        }
    }


    public final Sector sector;


    protected VolumeHyperbolic(Visualization data, double radius, double length, double volume){
        this(data,radius,length,volume,0.0,0.0);
    }
    protected VolumeHyperbolic(Visualization data, double radius, double length, double volume, 
                               double sectorMin, double sectorMax)
    {
        super(data,radius,length,volume);

        if (1.0 <= sectorMin && sectorMin < sectorMax)
            this.sector = new Sector(sectorMin,sectorMax);
        else
            this.sector = new Sector.Default();
    }


    public final float model(double u, double x){
        return this.sector.model(u,x);
    }
    public final float sector(double s){
        return this.sector.sector(s);
    }
}
